home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
GSRC208A.ZIP
/
GWTOP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-26
|
26KB
|
704 lines
#include "copyleft.h"
/*
GEPASI - a simulator of metabolic pathways and other dynamical systems
Copyright (C) 1989, 1992 Pedro Mendes
*/
/*************************************/
/* */
/* GWTOP - Topology */
/* MS-WINDOWS front end */
/* */
/* Topology window */
/* */
/* QuickC/WIN 1.0 */
/* */
/* (include here compilers that */
/* compiled GWSIM successfully) */
/* */
/*************************************/
/*
be sure that IOTOP.C is recompiled and that
it iotop.obj from a GWSIM compilation is not
being used now. To be sure, delete iotop.obj
*/
/* this is needed for IOTOP.C */
#define GWTOP
#include <windows.h>
#include <string.h>
#include "commdlg.h"
#include "basic.h" /* basic windows fnction prototypes */
#include "defines.h" /* symbols also used in .DLG files */
#include "globals.h" /* gepasi's own symbols */
#include "gwtop.h" /* macros, function prototypes, etc. */
#include "gep1.h" /* gepasi's variables */
#include "strtbl.h" /* symbols for the string table */
#include "iotop.h"
#pragma alloc_text( CODE0, WinMain, WndProc, AboutBox, nCwRegisterClasses, CwUnRegisterClasses, CleanUp )
#define HELP_PARTIALKEY 0x0105
/* Struct pointed to by WM_GETMINMAXINFO lParam
typedef struct tagMINMAXINFO
{
POINT ptReserved;
POINT ptMaxSize;
POINT ptMaxPosition;
POINT ptMinTrackSize;
POINT ptMaxTrackSize;
} MINMAXINFO;
*/
/* global variables */
char szString[128]; /* variable to load resource strings */
char szHelpFile[] = "GEPASI.HLP"; /* help file name */
char szAppName[20]; /* class name for the window */
int lbWidth; /* width of largest string in list box */
HWND hInst;
HWND hWndMain;
HCURSOR hHourGlass; /* handle to the wait cursor */
HMENU hMenu; /* handle to the menu */
GLOBALHANDLE hMetn; /* handle to memory block w/ metn */
GLOBALHANDLE hStepn; /* handle to memory block w/ stepn */
GLOBALHANDLE hSto; /* handle to memory block w/ sto */
GLOBALHANDLE hLp; /* handle to memory block w/ lp */
GLOBALHANDLE hKinet; /* handle to memory block w/ kinet */
GLOBALHANDLE hRs; /* handle to memory block w/ ord */
char (huge *metn)[NAME_L]; /* pointer to work with metname array */
char (huge *stepn)[NAME_L]; /* pointer to work with step names */
unsigned
char (huge *lp)[MAX_STEP][MAX_MET]; /* def. of modification loops */
int (huge *rs)[MAX_STEP][MAX_MOL]; /* reaction structure */
int huge *sto; /* pointer to work with metname array */
int totm; /* number of total metabolites */
int nst; /* number of steps */
int nlps; /* number of reactions with modifiers */
int intm[MAX_MET]; /* 1 if internal metabolite */
unsigned char rvr[MAX_STEP]; /* 1 if reaction is reversible */
int huge *kinet; /* pointer to mirror of kinetu */
unsigned char nmd[MAX_STEP]; /* number of assigned modfs of a react. */
int kinass, kass; /* number of reactions w/ defined type */
int loopass, lass; /* number of reactions w/ defined modif.*/
int notsaved; /* 1 if file has not been saved */
int eqefl; /* 1 if editing existing u-d rate eq. */
char FileName[256]; /* filename of file with full path */
char FileTitle[13]; /* filename of file w/o full path */
char errstr[80]; /* string to hold lex and parser errors */
unsigned char lex; /* index for parser */
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
/***********************************************************************/
/* HANDLE hInstance; handle for this instance */
/* HANDLE hPrevInstance; handle for possible previous instances */
/* LPSTR lpszCmdLine; long pointer to exec command line */
/* int nCmdShow; Show code for main window display */
/***********************************************************************/
MSG msg; /* MSG structure to store your messages */
int nRc; /* return value from Register Classes */
HANDLE hAcc;
LPSTR ptr;
strcpy(szAppName, "GWTOP");
hInst = hInstance;
if(!hPrevInstance)
{
/* register window classes if first instance of application */
if ((nRc = nCwRegisterClasses()) == -1)
{
/* registering one of the windows failed */
LoadString(hInst, IDS_ERR_REGISTER_CLASS, szString, sizeof(szString));
MessageBeep( MB_ICONHAND );
MessageBox(NULL, szString, NULL, MB_ICONSTOP);
return nRc;
}
}
/* setup the device independent screen units */
InitScrScale();
/* load the wait cursor */
hHourGlass = LoadCursor(NULL, IDC_WAIT);
/* load the accelerators table */
hAcc = LoadAccelerators( hInst, (LPSTR) "ACCTABLE" );
/* create application's Main window */
hWndMain = CreateWindow(
szAppName, /* Window class name */
"GEPASI - Topology", /* Window's title */
WS_CAPTION | /* Title and Min/Max */
WS_SYSMENU | /* Add system menu box */
WS_MINIMIZEBOX | /* Add minimize box */
WS_CLIPCHILDREN | /* don't draw in child windows areas */
WS_OVERLAPPED,
CW_USEDEFAULT, 0, /* Use default X, Y */
ScrX(150), ScrY(90),
NULL, /* Parent window's handle */
NULL, /* Default to Class Menu */
hInst, /* Instance of window */
NULL); /* Create struct for WM_CREATE */
if(hWndMain == NULL)
{
LoadString(hInst, IDS_ERR_CREATE_WINDOW, szString, sizeof(szString));
MessageBeep( MB_ICONHAND );
MessageBox(NULL, szString, NULL, MB_ICONSTOP);
return IDS_ERR_CREATE_WINDOW;
}
if( InitGepasiVar() != 0 ) /* initialize GEPASI's vars */
{
LoadString(hInst, IDS_ERR_OUT_OF_MEM, szString, sizeof(szString));
MessageBeep( MB_ICONHAND );
MessageBox(NULL, szString, NULL, MB_ICONSTOP);
if(!hPrevInstance) CwUnRegisterClasses();
return IDS_ERR_OUT_OF_MEM;
}
/* lets allocate memory for mirror of metname */
hMetn = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * NAME_L * sizeof( char ) );
if( hMetn == NULL )
{
LoadString(hInst, IDS_ERR_OUT_OF_MEM, szString, sizeof(szString));
MessageBeep( MB_ICONHAND );
MessageBox(NULL, szString, NULL, MB_ICONSTOP);
CleanUp(hWndMain, hPrevInstance);
return IDS_ERR_OUT_OF_MEM;
}
hStepn = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * NAME_L * sizeof( char ) );
if( hStepn == NULL )
{
LoadString(hInst, IDS_ERR_OUT_OF_MEM, szString, sizeof(szString));
MessageBeep( MB_ICONHAND );
MessageBox(NULL, szString, NULL, MB_ICONSTOP);
GlobalFree( hMetn );
CleanUp(hWndMain, hPrevInstance);
return IDS_ERR_OUT_OF_MEM;
}
/* lets allocate memory for mirror of stoiu */
hSto = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * MAX_STEP * sizeof( int ) );
if( hSto == NULL )
{
LoadString(hInst, IDS_ERR_OUT_OF_MEM, szString, sizeof(szString));
MessageBeep( MB_ICONHAND );
MessageBox(NULL, szString, NULL, MB_ICONSTOP);
GlobalFree( hStepn );
GlobalFree( hMetn );
CleanUp(hWndMain, hPrevInstance);
return IDS_ERR_OUT_OF_MEM;
}
/* mirror of loop */
hLp = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * MAX_MET * sizeof( unsigned char ) );
if( hLp == NULL )